<template>
  <div>
    <el-container>
      <el-aside width="200px">
        <el-menu v-if="this.identity==='系统管理员'">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-s-data"></i>数据管理</template>
            <el-menu-item-group>
              <el-menu-item index="1-1">
                <router-link to="/func/userList" style="text-decoration: none; color:#007fff">用户列表</router-link>
              </el-menu-item>
              <el-menu-item index="1-2">
                <router-link to="/func/evidenceList" style="text-decoration: none; color:#007fff">物证列表</router-link>
              </el-menu-item>
              <el-menu-item index="1-3">
                <router-link to="/func/organizationList" style="text-decoration: none; color:#007fff">组织机构</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title"><i class="el-icon-s-check"></i>鉴定管理</template>
            <el-menu-item-group>
              <el-menu-item index="2-1">
                <router-link to="/func/identifyList" style="text-decoration: none; color:#007fff">鉴定报表</router-link>
              </el-menu-item>
              <el-menu-item index="2-2">
                <router-link to="/func/identifyProvide" style="text-decoration: none; color:#007fff">鉴定提供信息</router-link>
              </el-menu-item>
              <el-menu-item index="2-3">
                <router-link to="/func/identifyResult" style="text-decoration: none; color:#007fff">鉴定结果</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="3">
            <template slot="title"><i class="el-icon-s-shop" ></i>设备管理</template>
            <el-menu-item-group>
              <el-menu-item index="3-1">
                <router-link to="/func/Instrument" style="text-decoration: none; color:#007fff">仪器信息</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title"><i class="el-icon-folder-opened" ></i>运行日志</template>
            <el-menu-item-group>
              <el-menu-item index="4-1">
                <a @click="downFile()" style="color: #007fff">下载日志</a>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
        <el-menu v-if="this.identity==='鉴定机构人员'">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-chat-dot-square"></i>鉴定管理</template>
            <el-menu-item-group>
              <el-menu-item index="1-1">
                <router-link to="/func/IidentifyList" style="text-decoration: none; color:#007fff">鉴定报表</router-link>
              </el-menu-item>
              <el-menu-item index="1-2">
                <router-link to="/func/IevidenceList" style="text-decoration: none; color:#007fff">物证列表</router-link>
              </el-menu-item>
              <el-menu-item index="1-3">
                <router-link to="/func/IidentifyResult" style="text-decoration: none; color:#007fff">鉴定结果</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title"><i class="el-icon-s-check"></i>信息管理</template>
            <el-menu-item-group>
              <el-menu-item index="2-1">
                <router-link to="/func/IInstrument" style="text-decoration: none; color:#007fff">仪器信息</router-link>
              </el-menu-item>
              <el-menu-item index="2-2">
                <router-link to="/func/IidentifyProvide" style="text-decoration: none; color:#007fff">鉴定方式信息</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
        <el-menu v-if="this.identity==='消防人员'">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-edit-outline"></i>信息管理</template>
            <el-menu-item-group>

              <el-menu-item index="1-2">
                <router-link to="/func/CidentifyList" style="text-decoration: none; color:#007fff">鉴定报表</router-link>
              </el-menu-item>
              <el-menu-item index="1-3">
                <router-link to="/func/CidentifyResult" style="text-decoration: none; color:#007fff">鉴定结果</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-document"></i>火灾鉴定</template>
            <el-menu-item-group>
              <el-menu-item index="2-1">
                <router-link to="/func/CevidenceList" style="text-decoration: none; color:#007fff">物证提交</router-link>
              </el-menu-item>
              <el-menu-item index="2-2">
                <router-link to="/func/CidentifyApplication" style="text-decoration: none; color:#007fff">鉴定申请</router-link>
              </el-menu-item>

            </el-menu-item-group>
          </el-submenu>
        </el-menu>
        <el-menu v-if="this.identity==='技术服务人员'">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-edit-outline"></i>信息管理</template>
            <el-menu-item-group>
              <el-menu-item index="1-1">
                <router-link to="/func/CidentifyList" style="text-decoration: none; color:#007fff">鉴定报表</router-link>
              </el-menu-item>
              <el-menu-item index="1-2">
                <router-link to="/func/CidentifyResult" style="text-decoration: none; color:#007fff">鉴定结果</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-document"></i>火灾鉴定</template>
            <el-menu-item-group>
              <el-menu-item index="2-1">
                <router-link to="/func/CidentifyApplication" style="text-decoration: none; color:#007fff">鉴定申请</router-link>
              </el-menu-item>
              <el-menu-item index="2-2">
                <router-link to="/func/CevidenceList" style="text-decoration: none; color:#007fff">物证提交</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
        <el-menu v-if="this.identity==='司法人员'">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-edit-outline"></i>信息管理</template>
            <el-menu-item-group>
              <el-menu-item index="1-1">
                <router-link to="/func/CidentifyList" style="text-decoration: none; color:#007fff">鉴定报表</router-link>
              </el-menu-item>
              <el-menu-item index="1-2">
                <router-link to="/func/CidentifyResult" style="text-decoration: none; color:#007fff">鉴定结果</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-document"></i>火灾鉴定</template>
            <el-menu-item-group>
              <el-menu-item index="2-1">
                <router-link to="/func/CevidenceList" style="text-decoration: none; color:#007fff">物证提交</router-link>
              </el-menu-item>
              <el-menu-item index="2-2">
                <router-link to="/func/CidentifyApplication" style="text-decoration: none; color:#007fff">鉴定申请</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
        <!--物证管理、报表管理、鉴定结果-->
        <!--物证管理、报表管理、鉴定结果-->
      </el-aside>

      <el-container class="movie-content">
        <el-header style="text-align: left; font-size: 12px;">
          <el-link :underline="false" type="primary" href="http://localhost:8080/main"
                   style="font-family: 楷体; font-size: 30px;font-weight: bolder; color: #fff ">火灾物证鉴定管理系统</el-link>
          <el-dropdown @command="handleCommand">
            <i class="el-icon-user" style="margin-left: 600px; font-size: 25px;color: #fff">{{this.username}}</i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="a" class="el-icon-setting">个人信息</el-dropdown-item>
              <el-dropdown-item command="b" class="el-icon-circle-close">注销</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-header>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
    <br><br><br>


    <el-container class= "full-width"style="margin-top:-10px; background-color: #72B6FF">
      <el-footer style="height:20px; position:relative;background-color: #72B6FF;display: inline-block;padding-left: 0px;padding-right: 0px">
        <div class="container fullwidth" style=" background-color: #72B6FF">
          <el-row :gutter="10" style="padding-top: -10px">
            <el-col :span="6"><div style="color: #72B6FF">&nbsp</div></el-col>
            <el-col :span="6"><div class="footer-main full-width"style="display: inline-block;vertical-align:baseline;">
              <br>
              <br>
              <h4 style="text-decoration: none; color: #fff;">社区</h4>
              <a href="https://gitee.com/im_goodman/vue-front-end/issues" target="_blank" class="footer-main-link" style="text-decoration: none; color: #fff">在线讨论</a>
              <a href="https://gitee.com/im_goodman/vue-front-end/issues" target="_blank" class="footer-main-link" style="text-decoration: none; color: #fff">反馈建议</a>
              <a href="https://gitee.com/im_goodman/vue-front-end" target="_blank" class="footer-main-link" style="text-decoration: none; color: #fff">贡献指南</a>
              <a href="https://gitee.com/im_goodman" target="_blank" class="footer-main-link" style="text-decoration: none; color: #fff">联系方式</a>
              <img src="http://icon.cnzz.com/img/pic.gif">
              <br><br><br>
            </div></el-col>
            <el-col :span="6"><div class="footer-social full-width" style="display: inline-block;background-color: #72B6FF" align="center ">
              <br>
              <br>
              <h4 class="footer-social-title" style="text-decoration: none; color: #fff">创作者 </h4>
              <div align="center" >
                <a class="mr-5 hover:opacity-90" target="_blank" rel="noreferrer" href="https://sakai.cqu.edu.cn" id="github"><img src="/static/github.png" alt=""></a>
                <a class="mr-5 hover:opacity-90" target="_blank" rel="noreferrer" href="https://twitter.com" id="twitter"><img src="/static/qq.png" alt=""></a>
                <a class="hover:opacity-90" target="_blank" rel="noreferrer" href="https://my.cqu.edu.cn" id="linkedin"><img src="/static/weixin.png" alt=""></a>
              </div>
            </div></el-col>
            <el-col :span="6"><div class="footer-social full-width" style="display: inline-block;background-color: #72B6FF" align="center ">
              <br>
              <br>
              <h4 class="footer-social-title" style="text-decoration: none; color: #fff">联系我们 </h4>
              <div align="center" >
                <a style="text-decoration: none; color: #fff" id="tel_no"> China +86 820 820 08 820</a>
              </div>
            </div></el-col>
          </el-row>

        </div>
      </el-footer>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "1test",
  data(){
    return{
      logurl:'',
      identity:'',
      username:''
    }
  },
  methods: {
    downFile(){
      this.axios({
        method:"post",
        headers: { 'content-type': 'application/json' },
        url: "http://evidence.frogking.cn/log/getLog",
        params:{
          token:localStorage.getItem("token_only"),
        }
      }).then(res=>{
        console.log(res)
        if(res["data"]["code"]==='800'){
          let a = document.createElement('a')
          window.location.href = res["data"]["item"]
        }
        else if(res["data"]["code"]==='801'){
          this.$alert('系统错误', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
            }
          });
        }
      }).catch(function (error) {
        console.log(error);
      });
    },
    handleCommand(command) {
      if(command==='b'){
        this.axios({
          method:"post",
          headers: { 'content-type': 'application/json' },
          url: "http://evidence.frogking.cn/loginController/unLogin",
          params:{
            token:localStorage.getItem("token_only"),
          }
        }).then(res=>{
          this.$router.push({path:'/login'})
        }).catch(function (error) {
          console.log(error);
        });
      }
      else if(command==='a'){
        this.$router.push("/func/profile");
      }
    },
    getData(){
      this.axios({
        method:"post",
        headers: { 'content-type': 'application/json' },
        url: "http://evidence.frogking.cn/userController/selectByUid",
        params:{
          token: localStorage.getItem("token_only")
        }
      }).then(res=>{
        if(res["data"]["code"]==='206'){
          this.username=res["data"]["item"]["username"];
          this.identity=res["data"]["item"]["identity"];
          if(this.identity==='系统管理员'){
            this.$notify({
              title: '欢迎',
              message: '您好，拥有权限的系统管理员！',
              type: 'success'
            });
          }
          else if(this.identity==='消防人员'){
            this.$notify({
              title: '欢迎',
              message: '您好，祝您好运，亲爱的消防员！',
              type: 'success'
            });
          }
          else if(this.identity==='技术服务人员'){
            this.$notify({
              title: '欢迎',
              message: '您好，技术部的同仁！',
              type: 'success'
            });
          }
          else if(this.identity==='鉴定机构人员'){
            this.$notify({
              title: '欢迎',
              message: '您好，今天也是刚正不阿的鉴定人员！',
              type: 'success'
            });
          }
          else if(this.identity==='司法人员'){
            this.$notify({
              title: '欢迎',
              message: '您好，惩恶扬善的司法人员！',
              type: 'success'
            });
          }
        }
        else if(res["data"]["code"]==='210'){
          this.$alert('系统错误', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.$router.push('/login')
            }
          });
        }
      }).catch(function (error) {
        console.log(error);
      });
    }
  },
  beforeRouteEnter: (to,from,next) => {
    console.log('进入路由之前');//加载数据
    next(vm => {
      vm.getData();//进入路由之前执行getData()
    })
  },
}
</script>

<style>
.movie-content
{
  min-height: 600px;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
.el-footer{
  position:relative;
  background-color: #333;
  color:#eee;
  text-align: center;
  font-size: 16px;
  height: 50px;
  margin-top: -10px;
  margin-left: 0px;
  margin-right: 0px;
}

.foot span{
  line-height: 50px;
}
.el-header {
  background-color:#1890ff;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
</style>

